//
//  EPMBottomView.m
//  WeiBoByOC
//
//  Created by 马继鵬 on 17/3/29.
//  Copyright © 2017年 7TH. All rights reserved.
//

#import "EPMBottomView.h"

@interface EPMBottomView()
@property (weak,nonatomic) UIButton* btnReweet;
@property (weak,nonatomic) UIButton* btnComment;
@property (weak,nonatomic) UIButton* btnApprecita;
@end
@implementation EPMBottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    UIButton* btnReweet = [self setBtnTiltle:@"转发" picture:@"timeline_icon_retweet"];
    _btnReweet = btnReweet;
    UIButton* btnComment = [self setBtnTiltle:@"评论" picture:@"timeline_icon_comment"];
    _btnComment = btnComment;
    UIButton* btnApprecita = [self setBtnTiltle:@"赞" picture:@"timeline_icon_unlike"];
    _btnApprecita = btnApprecita;
    
    [btnReweet mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.bottom.equalTo(self);
        make.width.equalTo(btnComment);
    }];
    [btnComment mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.leading.equalTo(btnReweet.mas_trailing);
        make.width.equalTo(btnApprecita);
    }];
    [btnApprecita mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.top.bottom.equalTo(self);
        make.leading.equalTo(btnComment.mas_trailing);
    }];
    UIImageView* imgline1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"timeline_card_bottom_line"]];
    [self addSubview:imgline1];
    UIImageView* imgLine2 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"timeline_card_bottom_line"]];
    [self addSubview:imgLine2];
    
    [imgline1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(btnReweet.mas_trailing);
        make.centerY.equalTo(btnReweet);
        make.width.mas_equalTo(1);
        make.height.equalTo(self.mas_height);
    }];
    
    [imgLine2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(btnComment.mas_trailing);
        make.centerY.equalTo(btnReweet);
        make.width.mas_equalTo(1);
        make.height.equalTo(self.mas_height);
    }];
    
    
}

- (UIButton*)setBtnTiltle:(NSString*)title picture:(NSString*)imgName
{
    UIButton* btn = [UIButton new];
    [btn setImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"timeline_card_bottom_background"] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"timeline_card_bottom_background_highlighted"] forState:UIControlStateHighlighted];
    [btn setTitle:title forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:FONTSIZENORMAL];
    [btn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [self addSubview:btn];
    return btn;
}

@end
